#!/user/bin/python3
# @Author:  LSY
# @Date:    2020/11/8
from app.models.bo.hanfan.hanfan_model_input_bo import HanFanModelInputBO
from app.services.models.base_model import BaseModel
from app.services.models.pickle_model import PickleModel
from flask import current_app
import pandas as pd
import numpy as np
from app.utils.constant import HanFanStatus


class LuzhaRModelV2(BaseModel):

    def __init__(self):
        super().__init__(model_name="luzha_r_model_v2")

    def process(self, input):
        try:
            b1 = input.get("CG_LT_GL_GL04_Zha_R", 0)
            b2 = input.get("CG_LT_GL_GL04_Zha_R_1", 0)
            y_R = b1 * 0.8 + b2 * 0.2
            return round(y_R, 3)
        except Exception as e:
            current_app.logger.info(e, exc_info=1)


class LuzhaTiO2ModelV2(BaseModel):

    def __init__(self):
        super().__init__(model_name="luzha_tio2_model_v2")

    def process(self, input):
        try:
            c1 = input.get("CG_LT_GL_GL04_Zha_TiO2", 0)
            c2 = input.get("CG_LT_GL_GL04_Zha_TiO2_1", 0)
            y_TiO2 = c1 * 0.8 + c2 * 0.2
            return round(y_TiO2, 3)
        except Exception as e:
            current_app.logger.info(e, exc_info=1)


class LuzhaMgAlModelV2(BaseModel):

    def __init__(self):
        super().__init__(model_name="luzha_mg_al_model_v2")

    def process(self, input):
        try:
            d1 = input.get("CG_LT_GL_GL04_Zha_Mg_Al", 0)
            d2 = input.get("CG_LT_GL_GL04_Zha_Mg_Al_1", 0)
            y_Mg_Al = d1 * 0.8 + d2 * 0.2
            return round(y_Mg_Al, 3)
        except Exception as e:
            current_app.logger.info(e, exc_info=1)


luzha_r_model = LuzhaRModelV2()
luzha_tio2_model = LuzhaTiO2ModelV2()
luzha_mg_al_model = LuzhaMgAlModelV2()
